package main

import (
	"fmt"
	"time"
)

func main() {
	//主协程退出，其他子协程也会退出
	go func() {
		i := 0
		for {
			i++
			fmt.Println("子协程 i= ", i)
			time.Sleep(time.Second)
		}
	}()

	i := 0
	for {
		i++
		fmt.Println("main i =", i)
		time.Sleep(time.Second)

		if i == 2 {
			break
		}
	}
}
